package com.vict.framework.pay.entity;

import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.alibaba.fastjson.annotation.JSONField;
import com.baomidou.mybatisplus.annotation.IEnum;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.vict.framework.fastjsonserializer.*;
import com.vict.framework.mybatishandler.JSONArrayTypeHandler;
import com.vict.framework.mybatishandler.JSONObjectTypeHandler;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.Getter;

import java.math.BigDecimal;
import java.sql.Timestamp;

@Data
@TableName("pay_order")
public class PayOrder {

    @ApiModelProperty(value="payDtoId")
    @TableId("pay_dto_id")
    private String payDtoId;

    @TableField("money")
    @ApiModelProperty(value="金额")
    @JSONField(serializeUsing = DecimalSerializer.class, deserializeUsing = DecimalDeserializer.class)
    private BigDecimal money;

    @TableField("pay_status")
    @ApiModelProperty(value="支付状态")
    @JSONField(serializeUsing = EnumSerializer.class, deserializeUsing = EnumDeserializer.class)
    private PayStatus payStatus;

    @Getter
    @AllArgsConstructor
    public enum PayStatus implements IEnum<String> {
        payStatus_wait("payStatus_wait", "待支付"),
        payStatus_success("payStatus_success", "已支付"),
        payStatus_cancel("payStatus_cancel", "已取消"),
        ;
        private String value;
        private String name;
    }

    @TableField("pay_type")
    @ApiModelProperty(value="支付方式")
    @JSONField(serializeUsing = EnumSerializer.class, deserializeUsing = EnumDeserializer.class)
    private PayType payType;

    @Getter
    @AllArgsConstructor
    public enum PayType implements IEnum<String> {
        payType_cash("payType_cash", "现金"),
        payType_WeiXin("payType_yinShengWeiXin", "微信"),
        payType_ZhiFuBao("payType_yinShengWeiXin", "支付宝"),
        ;
        private String value;
        private String name;
    }

    @TableField("start_time")
    @ApiModelProperty(value="创建时间")
    @JSONField(serializeUsing = TimestampSerializer.class, deserializeUsing = TimestampDeserializer.class)
    private Timestamp startTime;

    @TableField("over_time")
    @ApiModelProperty(value="过期时间")
    @JSONField(serializeUsing = TimestampSerializer.class, deserializeUsing = TimestampDeserializer.class)
    private Timestamp overTime;

    @TableField("success_time")
    @ApiModelProperty(value="支付成功时间")
    @JSONField(serializeUsing = TimestampSerializer.class, deserializeUsing = TimestampDeserializer.class)
    private Timestamp successTime;

    @TableField("cancel_time")
    @ApiModelProperty(value="取消时间")
    @JSONField(serializeUsing = TimestampSerializer.class, deserializeUsing = TimestampDeserializer.class)
    private Timestamp cancelTime;

    @TableField("is_back")
    @ApiModelProperty(value="退款标记")
    @JSONField(serializeUsing = IntegerSerializer.class, deserializeUsing = IntegerDeserializer.class)
    private Integer isBack;

    @TableField("pay_remark")
    @ApiModelProperty(value="支付备注")
    private String payRemark;

    @TableField("class_name")
    private String className;

    @TableField("method_name")
    private String methodName;

    @TableField(value = "args", typeHandler = JSONArrayTypeHandler.class)
    private JSONArray args;

    @TableField(value = "user_context", typeHandler = JSONObjectTypeHandler.class)
    private JSONObject userContext;
}
